package jin.competition.jan18co11_2;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;



public class UpdateA {
	public boolean update(User u) {
		BaseDao bd = new BaseDao();
		Connection con = bd.getCon();
		String sql = "update user set pwd =? where id=?";

		try {
			PreparedStatement ps = con.prepareStatement(sql); // 执行连接数据库的sql语句
			ps.setString(1, u.getPwd());
			ps.setInt(2, u.getId());

			ps.execute();
			if (ps != null) {
				ps.close();
			}
			if (con != null) {
				con.close();
			}

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return true;
	}

}
// 2. 通过java 查询，修改一个用户的密码。